---
layout: start.swig
title: 小程序域名白名单配置
---
<script src="//cdn.jsdelivr.net/npm/leancloud-storage@3.11.0-beta.0/dist/av-min.js"></script>
<div class="start-page doc-content" ng-controller="WeappDomainsCtrl" >
  <h1 class="font-logo">小程序域名白名单配置</h1>
  <!-- .doc-home-title -->
  <div class="login" ng-if="!user.username">
    <a ng-href="/login.html#/signin" class="btn  btn-primary ng-scope">登录</a>
    <p class="help-block">查看域名白名单配置，需要先登录。</p>
  </div>
  
  <div class="step">
    <h3>1. 登录微信公众平台</h3>
    <div class="row" ng-if="user.username && apps">
      <div class="step-content col-sm-12">
        <p>登录 <a href="https://mp.weixin.qq.com" target="_blank">微信公众平台</a>，前往 <strong>设置</strong> &gt; <strong>开发设置</strong> &gt; <strong>服务器配置</strong> &gt; <strong>「修改」</strong>链接。</p>
      </div>
    </div>
  </div>

  <div class="step">
    <h3>2. 选择应用节点</h3>
    <div class="row">
      <div class="step-content col-sm-12">
        <ul>
          <li>{% if node !== undefined %}<a href="https://leancloud.cn/docs/weapp-domains.html">{% endif %}华北节点{% if node !== undefined %}</a>{% endif %}{% if node === undefined %}<span class="text-muted">（当前）</span>{% endif %}</li>
          <li>{% if node !== 'qcloud' %}<a href="https://tab.leancloud.cn/docs/weapp-domains.html">{% endif %}华东节点{% if node !== 'qcloud' %}</a>{% endif %}{% if node === 'qcloud' %}<span class="text-muted">（当前）</span>{% endif %}</li>
          <li>{% if node !== 'us' %}<a href="https://us.leancloud.cn/docs/weapp-domains.html">{% endif %}美国节点{% if node !== 'us' %}</a>{% endif %}{% if node === 'us' %}<span class="text-muted">（当前）</span>{% endif %}</li>
        </ul>
      </div>
    </div>
  </div>

  <div class="step">
    <h3>3. 选择 LeanCloud 应用，增加<span ng-if="user.username && apps">以下域名：</span><span ng-if="!(user.username && apps)">必要的域名。</span></h3>
    <div class="row" ng-if="user.username">
      <div class="step-content col-sm-4" ng-show="apps">
        <select class="form-control custom-select btn btn-default" ng-model="pageState.currentApp"  ng-options="app.app_name  for app in apps">
        </select>
      </div>
      <div class="step-content col-sm-8" ng-show="apps">
        <small class="text-warning" style="line-height: 2.5;">不同的应用，对应不同的域名。</small>
      </div>
      <div class="step-content col-sm-12" ng-hide="apps">
        <form ng-hide="apps.all" class="form-inline">
          <a ng-href="/applist.html#/newapp" class="btn  btn-primary create-app ng-scope" translate="ACTION_CREATE_APP">创建应用</a>
          <p class="help-block" style="">您目前还没有创建任何应用，需要先创建应用后，才能看到应用所对应的域名列表。</p>
        </form>
      </div>
    </div>
    <div class="row" ng-if="user.username && apps">
      <div class="step-content col-sm-12">
        <table>
          <tr>
            <th rowspan="{{ requestDomainsLength }}" width="40%"><strong>request 域名</strong><small class="help-block text-warning mb-0">所列出的域名都要添加，缺一不可。</small></th>
              <td>app-router.leancloud.cn</td>
          </tr>
          <tr ng-repeat="domain in extraRequestDomains">
            <td>{{domain}}</td>
          </tr>
          <tr>
            <th><strong>uploadFile 域名</strong></th>
            <td ng-bind="domains.upload"></td>
          </tr>
          <tr>
            <th><strong>downloadFile 域名</strong><small class="help-block mb-0">仅在使用 <code>wx.downloadFile</code> 时需要配置</small><small class="help-block text-warning mb-0">需要先 <a href="/dashboard/storage.html?appid={{appid}}#/storage/conf" target="_blank">绑定文件自定义域名</a><super>*<s/super></small></th>
            <td ng-bind="domains.download"></td>
          </tr>
          {% if node === 'us' %}
            {% set area = 'us-w1-backend' %}
            {% set arr = [3, 4, 5, 6, 7, 8, 9] %}
          {% elseif node === 'qcloud' %}
            {% set area = 'cn-e1-cell' %}
            {% set arr = [2, 3, 4, 5, 6] %}
          {% else %}
            {% set area = 'cn-n1-cell' %}
            {% set arr = [1, 2, 5, 7] %}
          {% endif %}
          {% for i in arr %}
            <tr>
              {% if loop.first %}
                <th rowspan="<%= loop.length %>"><strong>socket 域名</strong><small class="help-block mb-0">仅在使用即时通讯功能时需要配置</small><small class="help-block text-warning mb-0">所列出的域名都要添加，缺一不可。</small></th>
              {% endif %}
              <td><%= area %><%= i %>.leancloud.cn</td>
            </tr>
          {% endfor %}
        </table>

        <div class="callout callout-info">* 我们提供的 downloadFile 域名是 LeanCloud 平台上的所有应用共享的，这个域名有可能会被微信识别为违规域名而被封禁。因此在使用该功能前，请先绑定您自己的文件域名来避免风险。</div>
      </div>
    </div>
  </div>

</div>
